﻿namespace TowerOfHanoi
{
    internal class Program
    {
        /// <summary>
        ///汉诺塔游戏过程
        /// </summary>
        /// <param name="args"></param>
        static void TowerOfHanoi (int n,string TowerA,string TowerB,String TowerC)
        {   
            if(n==1)
            //最后一步，从A到C
            {
                Console.WriteLine($"Move numner {n} from {TowerA} to {TowerC}");
            }
            else 
            //每次都把n-1层看成一个整体
            {   //n-1层从A到B
                TowerOfHanoi(n - 1, TowerA, TowerC, TowerB);
                //n层从A到C
                Console.WriteLine($"Move number {n} from {TowerA} to {TowerC}");
                //n-1层从B到C
                TowerOfHanoi(n - 1, TowerB, TowerA, TowerC);
            }

        }
        static void Main(string[] args)
        {
            Console.WriteLine("请输入汉诺塔层数");
            int num = Convert.ToInt32(Console.ReadLine());
            TowerOfHanoi(num, "A", "B", "C");

        }
    }
}